package com.example.workshop.lesson7;
import com.example.workshop.lesson7.RecommenderImplementation;
import com.example.workshop.lesson7.RecommenderImplementation2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.util.Arrays;

@SpringBootApplication
public class MovieRecommenderSystemApplication {

    public static void main(String[] args) {
        //ApplicationContext负责管理Bean和依赖关系。
        ApplicationContext appContext= SpringApplication.run(
                MovieRecommenderSystemApplication.class,args
        );

        //RecommenderImplementation构造方法注入依赖关系
        System.out.println("\n***************************");
        System.out.println("Calling getBean() on RecommenderImplementation");
        RecommenderImplementation ri=appContext.getBean(RecommenderImplementation.class);
        String results[]=ri.recommendMovies("星际穿越");
        System.out.println(Arrays.toString(results));

        //RecommenderImplementation2 setter方法注入依赖
        System.out.println("\n****************************");
        System.out.println("Calling getBean() on RecommenderImplementation2");
        RecommenderImplementation2 ri2 =appContext.getBean(RecommenderImplementation2.class);
        results=ri2.recommendMovies("星际穿越");
        System.out.println(Arrays.toString(results));
    }
}


